﻿using System;
using RockCorn.Internals;

namespace RockCorn.Objects.Moving
{
    class DestroyerObject : MovingObject
    {
        public new const string CollisionGroupString = "destroyer";

        public override string GetCollisionGroupString()
        {
            return DestroyerObject.CollisionGroupString;
        }

        public DestroyerObject(MatrixCoords topLeft, MatrixCoords speed)
            : base(topLeft, new char[,] { { ' ' } }, speed)
        {
        }

        public override bool CanCollideWith(string otherCollisionGroupString)
        {
            return true;
        }

        public override void RespondToCollision(CollisionData collisionData)
        {
            if (collisionData.CollisionForceDirection.Row * this.Speed.Row < 0)
            {
                this.Speed.Row *= -1;
            }
            if (collisionData.CollisionForceDirection.Col * this.Speed.Col < 0)
            {
                this.Speed.Col *= -1;
            }
        }

        public override void Update()
        {
            this.IsDestroyed = true;
        }
    }
}
